<template>
	<div>
		<!-- 面包屑导航区 -->
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item>首页</el-breadcrumb-item>
			<el-breadcrumb-item>用户管理</el-breadcrumb-item>
			<el-breadcrumb-item>用户列表</el-breadcrumb-item>
			<el-breadcrumb-item>用户修改</el-breadcrumb-item>
		</el-breadcrumb>
		<el-form :model="orderlist" ref="orderlist" label-width="170px" style="margin: 20px auto;width: 60%;">
			<el-form-item label="用户名" prop="user_name">
				<el-input v-model="orderlist.user_name"></el-input>
			</el-form-item>
			<el-form-item label="用户密码" prop="user_password">
				<el-input v-model="orderlist.user_password"></el-input>
			</el-form-item>
			<el-form-item label="用户创建账号时间" prop="user_create_time">
				<el-input v-model="orderlist.user_create_time"></el-input>
			</el-form-item>
			<el-form-item label="用户上次登录账号时间" prop="user_last_login">
				<el-input v-model="orderlist.user_last_login"></el-input>
			</el-form-item>
			<el-form-item label="用户状态" prop="user_status">
				<el-select v-model="orderlist.user_status" placeholder="请选择">
					<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item style="float: right;">
				<el-button type="primary" @click="submit()">修改</el-button>
				<el-button @click="reset('orderlist')">重置</el-button>
				<el-button type="info" @click="goBack()">返回</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
import axios from "axios";
export default{
	name: "edituser",
	data(){
		return{
			options: [{
				value: '正常',
				label: '正常'
			}, {
				value: '异常',
				label: '异常'
			}],
			 orderlist: {},
		}
	},
	methods:{
		getInfo(){
			let id = this.$route.query.user_id;
			axios.get('http://localhost:8080/user/findById?user_id='+id)
			.then(res=>{
				this.orderlist = res.data;
			});
		},
		submit(){
			axios.post("http://localhost:8080/user/update", this.orderlist)
			.then(res=>{
				console.log(res.data);
				this.$message('修改订单成功！');
				history.back();
			},err=>{
				console.log(err);
			})
		},
		reset(formName){
			this.$refs[formName].resetFields();
		},
		goBack(){
			history.back();
		}
	},
	created(){
		this.getInfo();
	}
}
</script>

<style>
</style>
